package com.sx.service.system;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sx.entity.system.MenuEntity;
import com.sx.mapper.system.MenuMapper;
import com.sx.basic.BasicService;
import com.sx.basic.impl.BasicServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author AdinZ
 * @date 2020/11/7 18:13
 */
@Service
public class MenuService extends BasicServiceImpl<MenuMapper, MenuEntity>
        implements BasicService<MenuEntity>, IMenuService {


    @Override
    public List<MenuEntity> findMenu(MenuEntity.Action action) {
        List<MenuEntity> list = this.redisService.get(MenuEntity.KEY(action), 0, -1);
        if(list==null||list.size()==0){
            list = this.list(new QueryWrapper<MenuEntity>().eq("action", action));
            if(list!=null&&list.size()>0){
                this.redisService.set(MenuEntity.KEY(action),list);
            }
        }
        return list;
    }
}
